(library (lib function-combinators)
  (export combine)

  (import
   (except (rnrs base) let-values map)
   (only (guile)
         lambda* λ))

  (define combine-binary-op
    (λ (proc1 proc2)
      (λ (in)
        (proc2
         (proc1 in)))))


  (define combine
    (λ (proc . other-procs)
      (cond
       [(null? other-procs) proc]
       [else
        (combine-binary-op proc
                           (apply combine other-procs))]))))
